package com.easyspringboot.utils;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Author xiaoyi
 * @Version 1.0
 * @ClassName DateUtils
 * @Time 0:04
 */
public class DateUtils {

    public static final String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
    public static final String YYYYMMDD= "yyyyMMdd";
    public static final String _YYYYMMDD = "yyyy/MM/dd";
    public static String format(Date date, String pattern){
        if(null==date){
            return null;
        }
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
        return simpleDateFormat.format(date);
    }
    public static Date parse(String date, String pattern) throws Exception {
        if(null==date){
            return null;
        }
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
        return simpleDateFormat.parse(date);
    }
}
